<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>

<head>
    <title>新增网点</title>

</head>

<body>

<script type="application/javascript">
    var success = "${success}";
    if(success!=null &&success!=""&& success!= undefined){
        showMyDialog("温馨提示","网点创建成功",function(){
            window.location='${ctx}/workbench/networks';
        },'sm',false);
    }
</script>
    <div class="container">
        <div div="row">
            <div class="col-sm-10">
                <div class="row">
                    <div class="panel panel-default">
                        <div class="panel-heading">新增网点</div>
                        <div class="panel-body">
                            <sf:form role="form" class="form-horizontal" commandName="companyNetwork" action="${ctx}/workbench/network/add" method="post">
                                <div class="row">

                                    <div class="form-group">
                                        <label for="inputLocation" class="col-sm-2 control-label">所在地:</label>
                                        <div class="col-sm-3">
                                            <div class="input-group">
                                                <input id="inputLocation" name="location.locationName" value="${companyNetwork.location.locationName}" type="text" class="form-control"  readonly>
                                                <input id="inputLocationHidden" name="location.locationId" value="${companyNetwork.location.locationId}"type="hidden">
                                                <div class="input-group-btn">
                                                    <button id="btnLocation" type="button" class="btn btn-default"><span class="glyphicon glyphicon-globe"></span></button>
                                                </div>
                                            </div>
                                            <div class="help-block with-errors">
                                                <sf:errors path="location" cssClass="alert alert-danger"
                                                           element="div"></sf:errors>
                                            </div>
                                        </div>

                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label"><span class="text-warning">*</span>网点名称:</label>
                                        <div class="col-sm-3">
                                            <input type="text" class="form-control" name="networkName" value="${companyNetwork.networkName}">
                                            <div class="help-block with-errors">
                                                <sf:errors path="networkName" cssClass="alert alert-danger"
                                                           element="div"></sf:errors>
                                            </div>
                                        </div>

                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">详细地址:</label>
                                        <div class="col-sm-5">
                                            <input class="form-control" name="address" value="${companyNetwork.address}" type="text">
                                            <div class="help-block with-errors">
                                                <sf:errors path="address" cssClass="alert alert-danger"
                                                           element="div"></sf:errors>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">联系人:</label>
                                        <div class="col-sm-3">
                                            <input class="form-control" name="contacts[0].contactName" value="${companyNetwork.contacts[0].contactName}" type="text">
                                            <div class="help-block with-errors">
                                                <sf:errors path="contacts[0].contactName" cssClass="alert alert-danger"
                                                           element="div"></sf:errors>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">联系电话</label>
                                        <div class="col-sm-3">
                                            <input class="form-control" name="contacts[0].contactAccount" value="${companyNetwork.contacts[0].contactAccount}" type="tel">
                                            <input type="hidden" name="contacts[0].contactType" value="2"/>
                                            <div class="help-block with-errors">
                                                <sf:errors path="contacts[0].contactAccount" cssClass="alert alert-danger"
                                                           element="div"></sf:errors>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">QQ:</label>
                                        <div class="col-sm-3">
                                            <input class="form-control" name="contacts[1].contactAccount" value="${companyNetwork.contacts[1].contactAccount}" type="text">
                                            <input type="hidden" name="contacts[1].contactType" value="3"/>
                                            <div class="help-block with-errors">
                                                <sf:errors path="contacts[1].contactAccount" cssClass="alert alert-danger"
                                                           element="div"></sf:errors>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">状态:</label>
                                        <div class="col-sm-3">
                                            <select name="status" class="form-control">
                                                <option value="1" <c:if test="${companyNetwork.status==1 or companyNetwork.status==null}">selected</c:if> >已开通</option>
                                                <option value="2" <c:if test="${companyNetwork.status==2}">selected</c:if> >未开通</option>

                                                <%--<c:if test="${companyNetwork.status==1 or companyNetwork.status==null}">--%>
                                                    <%--<option value="1" selected>已开通</option>--%>
                                                    <%--<option value="2">未开通</option>--%>
                                                <%--</c:if>--%>
                                                <%--<c:if test="${companyNetwork.status==2}">--%>
                                                    <%--<option value="1">已开通</option>--%>
                                                    <%--<option value="2" selected>未开通</option>--%>
                                                <%--</c:if>--%>
                                            </select>
                                            <div class="help-block with-errors">
                                                <sf:errors path="contacts[1].contactAccount" cssClass="alert alert-danger"
                                                           element="div"></sf:errors>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="txtAreaRemark" class="col-md-2 control-label"><span
                                                class="text-danger"></span>备注:</label>

                                        <div class="col-md-6">
                                    <textarea id="txtAreaRemark" name="remark" class="form-control"
                                      placeholder="">${companyNetwork.remark}</textarea>
                                            <div class="help-block with-errors">
                                                <sf:errors path="remark" cssClass="alert alert-danger" element="div"></sf:errors>
                                            </div>
                                        </div>
                                    </div>

                                    <!-- /input-group -->
                                    <button type="submit" class="btn btn-success col-sm-offset-2">新增</button>
                                    <button type="button" class="btn btn-warning" onclick="javascript:location='${ctx}/workbench/networks'">取消</button>
                                </div>
                            </sf:form>
                        </div>

                    </div>

                </div>


            </div>

        </div>
    </div>




    <!-- Large modal -->

    <div id="myRegionSelectorModal" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">地区选择</h4>
                </div>
                <div class="modal-body">
                    <div class="container" id="divRegionSelector"></div>
                </div>

            </div>
        </div>
    </div>

    <script src="${ctx}/statics/echarts/echarts.min.js"></script>
    <script src="${ctx}/statics/js/regionselector.js"></script>


    <script>
        $(function () {

            $("#networkmanagement-tab").addClass("active");
            //地图选择器
            var myRegionSelector = regionselector.init('divRegionSelector');
            myRegionSelector.click(function (param) {
                alert(param.value);

            });

            //始发地选择
            $('#btnLocation').click(function () {
                myRegionSelector.reset();
                $('#myRegionSelectorModal').modal();
                myRegionSelector.click(function (param) {
                    $('#inputLocation').val(param.text);
                    $('#inputLocationHidden').val(param.value);
                    $('#myRegionSelectorModal').modal('hide');

                });
            });


        })
    </script>

</body>

</html>